function ajoutTache(t,e,r){ //ajoute champs Tache-Echeance-Responsable
	if (typeof t === 'undefined') //si il n'y a pas d'arg
		$('#ajoutTache').before('<tr><td><input type="text" name="TacheRealise[]" class="champ" onBlur="verifChamp(this)" onFocus="blanc(this)"/></td><td><input type="text" name="Echeance[]" class="champ" onBlur="verifChamp(this)" onFocus="blanc(this)" /></td><td><input type="text" name="Responsable[]" class="champ" onBlur="verifChamp(this)" onFocus="blanc(this)" /></td><td><input type="button" value="-" onClick="enleveLigne(this,\'tabTache\')"/></td></tr>');
	else //lors de la correction
		$('#ajoutTache').before('<tr><td><input type="text" name="TacheRealise[]" class="champ" value="'+t+'" onBlur="verifChamp(this)" onFocus="blanc(this)"/></td><td><input type="text" name="Echeance[]" class="champ" value="'+e+'" onBlur="verifChamp(this)" onFocus="blanc(this)"/></td><td><input type="text" name="Responsable[]" class="champ" value="'+r+'" onBlur="verifChamp(this)" onFocus="blanc(this)"/></td><td><input type="button" value="-" onClick="enleveLigne(this,\'tabTache\')"/></td></tr>');
}

function ajoutDepense(n,b,f){ //ajoute champs NatureDepense-BudgetDepense-Fournisseur
	if (typeof n === 'undefined')
		$('#ajoutDepense').before('<tr><td><input type="text" name="NatureDepense[]" class="champ" onBlur="verifChamp(this)" onFocus="blanc(this)"/></td><td><input type="text" name="BudgetDepense[]" class="champ" onBlur="verifChamp(this)" onFocus="blanc(this)"/></td><td><input type="text" name="Fournisseur[]" class="champ" onBlur="verifChamp(this)" onFocus="blanc(this)" /></td><td><input type="button" value="-" onClick="enleveLigne(this,\'tabDepense\')"/></td></tr>');
	else
		$('#ajoutDepense').before('<tr><td><input type="text" name="NatureDepense[]" class="champ" value="'+n+'" onBlur="verifChamp(this)" onFocus="blanc(this)"/></td><td><input type="text" name="BudgetDepense[]" class="champ" value="'+b+'" onBlur="verifChamp(this)" onFocus="blanc(this)"/></td><td><input type="text" name="Fournisseur[]" class="champ" value="'+f+'" onBlur="verifChamp(this)" onFocus="blanc(this)" /></td><td><input type="button" value="-" onClick="enleveLigne(this,\'tabDepense\')"/></td></tr>');
}

function ajoutRecette(n,b){ //ajoute champs NatureRecette-BudgetRecette
	if (typeof b === 'undefined')
		$('#ajoutRecette').before('<tr><td><input type="text" name="NatureRecette[]" class="champ" onBlur="verifChamp(this)" onFocus="blanc(this)"/></td><td><input type="text" name="BudgetRecette[]" class="champ" onBlur="verifChamp(this)" onFocus="blanc(this)"/></td><td><input type="button" value="-" onClick="enleveLigne(this,\'tabRecette\')"/></td></tr>');
	else
		$('#ajoutRecette').before('<tr><td><input type="text" name="NatureRecette[]" class="champ" value="'+n+'" onBlur="verifChamp(this)" onFocus="blanc(this)"/></td><td><input type="text" name="BudgetRecette[]" class="champ" value="'+b+'" onBlur="verifChamp(this)" onFocus="blanc(this)"/></td><td><input type="button" value="-" onClick="enleveLigne(this,\'tabRecette\')"/></td></tr>');
}

function verifChamp(champ){
	if(champ.value=="")
		champ.style.backgroundColor = "red";
}

function enleveLigne(input,id){
	var ligne = input.parentNode.parentNode;
	document.getElementById(id).deleteRow(ligne.rowIndex);
}

function blanc(champ)
{
	champ.style.backgroundColor = "white";
}

function verifFormulaire(){
	var tab = document.getElementsByClassName("champ");
	var erreur = false;
	for(var i = 0; i < tab.length; i++)
	{
		if(tab[i].value=="")
		{
			erreur = true;
			tab[i].style.backgroundColor = "red";
		}
	}
	if(erreur)
	{
		document.getElementById("erreur").innerHTML="Des erreurs sont survenues, vérifiez vos saisies.";
		return false;
	}
	else
		return true;
}

